package com.bestow.lease.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.lease.domain.HlsBpMasterAddress;
import com.bestow.lease.service.IHlsBpMasterAddressService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 商业伙伴地址信息Controller
 * 
 * @author liliu
 * @date 2022-09-26
 */
@RestController
@RequestMapping("/lease/bpMasterAddress")
public class HlsBpMasterAddressController extends BaseController
{
    @Autowired
    private IHlsBpMasterAddressService hlsBpMasterAddressService;

    /**
     * 查询商业伙伴地址信息列表
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsBpMasterAddress hlsBpMasterAddress)
    {
        startPage();
        List<HlsBpMasterAddress> list = hlsBpMasterAddressService.selectHlsBpMasterAddressList(hlsBpMasterAddress);
        return getDataTable(list);
    }

    /**
     * 导出商业伙伴地址信息列表
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:export')")
    @Log(title = "商业伙伴地址信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsBpMasterAddress hlsBpMasterAddress)
    {
        List<HlsBpMasterAddress> list = hlsBpMasterAddressService.selectHlsBpMasterAddressList(hlsBpMasterAddress);
        ExcelUtil<HlsBpMasterAddress> util = new ExcelUtil<HlsBpMasterAddress>(HlsBpMasterAddress.class);
        util.exportExcel(response, list, "商业伙伴地址信息数据");
    }

    /**
     * 获取商业伙伴地址信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:query')")
    @GetMapping(value = "/{addressId}")
    public AjaxResult getInfo(@PathVariable("addressId") Long addressId)
    {
        return AjaxResult.success(hlsBpMasterAddressService.selectHlsBpMasterAddressByAddressId(addressId));
    }

    /**
     * 新增商业伙伴地址信息
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:add')")
    @Log(title = "商业伙伴地址信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsBpMasterAddress hlsBpMasterAddress)
    {
        return toAjax(hlsBpMasterAddressService.insertHlsBpMasterAddress(hlsBpMasterAddress));
    }

    /**
     * 修改商业伙伴地址信息
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:edit')")
    @Log(title = "商业伙伴地址信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsBpMasterAddress hlsBpMasterAddress)
    {
        return toAjax(hlsBpMasterAddressService.updateHlsBpMasterAddress(hlsBpMasterAddress));
    }

    /**
     * 删除商业伙伴地址信息
     */
    @PreAuthorize("@ss.hasPermi('lease:bpMasterAddress:remove')")
    @Log(title = "商业伙伴地址信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{addressIds}")
    public AjaxResult remove(@PathVariable Long[] addressIds)
    {
        return toAjax(hlsBpMasterAddressService.deleteHlsBpMasterAddressByAddressIds(addressIds));
    }
}
